//
//  CityShopkeeperListTableViewCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/7/17.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "MeatCityFriendTableViewCell.h"

@implementation MeatCityFriendTableViewCell

- (void)setupUI{
   
    self.backgroundColor = UIColorFromRGB(0xFAFAF9);
    [self addSubview:self.mContentView];
}

- (void)setupLayout{
    
    _shopNameLab.text = @"呆萌小猪宝";
    _shopContentLab.text = @"立志用功如种树然，方其根芽，犹未有干！";
    _shopAgeLab.text = @"年龄：18";
    
    _mContentView.frame = CGRectMake(0, 0, KScreenWidth, 178);

    
    _shopIcon.size = CGSizeMake(42, 42);
    _shopIcon.mj_x = _shopIcon.mj_y = 15;
    
    //店铺名称
    _shopNameLab.mj_x = 12 + _shopIcon.right;
    _shopNameLab.mj_y = 18;
    _shopNameLab.width = KScreenWidth - _shopNameLab.left - [self fitSize:15];
    _shopNameLab.height = 20;
    
    
    //店铺年龄
    _shopAgeLab.mj_x = _shopNameLab.left;
    _shopAgeLab.mj_y = _shopNameLab.bottom + 4;
    _shopAgeLab.width = _shopNameLab.width;
    _shopAgeLab.height = 17;
    
    
    //店铺内容
    _shopContentLab.mj_x = 15;
    _shopContentLab.mj_y = 13 +_shopAgeLab.bottom;
    _shopContentLab.width = KScreenWidth - 30;
    _shopContentLab.height = 20;
    
    
    _bottomView.mj_x = 15;
    _bottomView.mj_y = _mContentView.height - _bottomView.height - 15;

}


#pragma mark - setter and getter

- (UIView *)mContentView{
    
    if (!_mContentView) {
        _mContentView = [UIView new];
        _mContentView.backgroundColor = KWhiteColor;
        
        [_mContentView addSubview:self.shopIcon];
        
        //店铺名称
        [_mContentView addSubview:self.shopNameLab];
        
        //店铺内容
        [_mContentView addSubview:self.shopContentLab];
        
        //年龄
        [_mContentView addSubview:self.shopAgeLab];
        
        [_mContentView addSubview:self.bottomView];

    }
    return _mContentView;
}


- (UIImageView *)shopIcon{
    
    if (!_shopIcon) {
        _shopIcon = [[UIImageView alloc] init];
        _shopIcon.image = [UIImage imageNamed:@"meat_list"];
        [self addShadowAndCircleCorner:_shopIcon.layer corner:21];
    }
    return _shopIcon;
}


//店主性别
- (UIImageView *)shopGenderIcon{
    
    if (!_shopGenderIcon) {
        _shopGenderIcon = [[UIImageView alloc] init];
        _shopGenderIcon.size = CGSizeMake(14, 14);
        _shopGenderIcon.image = [UIImage imageNamed:@"meat_list"];
    }
    return _shopGenderIcon;
}


//店铺名称
- (UILabel *)shopNameLab{
    
    if (!_shopNameLab) {
        _shopNameLab = [[UILabel alloc] init];
        _shopNameLab.textColor = UIColorFromRGB(0x333333);
        _shopNameLab.font = mMediumFont(15);
    }
    return _shopNameLab;
}

//店铺年龄
- (UILabel *)shopAgeLab{
    
    if (!_shopAgeLab) {
        _shopAgeLab = [[UILabel alloc] init];
        _shopAgeLab.font = mFont(12);
        _shopAgeLab.textColor = UIColorFromRGB(0xB2B2B2);
    }
    return _shopAgeLab;
}


//店铺内容
- (UILabel *)shopContentLab{
    
    if (!_shopContentLab) {
        _shopContentLab = [[UILabel alloc] init];
        _shopContentLab.font = mFont(14);
        _shopContentLab.textColor = UIColorFromRGB(0x7F7F7F);
        _shopContentLab.numberOfLines = 0;
    }
    return _shopContentLab;
}

//店铺距离
- (UILabel *)shopLocationLab{
    
    if (!_shopLocationLab) {
        _shopLocationLab = [[UILabel alloc] init];
        _shopLocationLab.font = mFont(12);
        _shopLocationLab.textColor = UIColorFromRGB(0xB2B2B2);
        _shopLocationLab.textAlignment = NSTextAlignmentRight;
    }
    return _shopLocationLab;
}


//
- (UIView *)bottomView{
    
    if (!_bottomView) {
        _bottomView = [UIView new];
        _bottomView.backgroundColor = UIColorFromRGB(0xFAFAF9);
        _bottomView.size = CGSizeMake(KScreenWidth - 30, 58);
        [self addShadowAndCircleCorner:_bottomView.layer corner:3];
        
        [_bottomView addSubview:self.addFriendBtn];
        _addFriendBtn.mj_x = _addFriendBtn.mj_y = 0;
        
        [_bottomView addSubview:self.addShopBtn];
         _addShopBtn.mj_y = 0;
        _addShopBtn.mj_x =_addFriendBtn.right;
        
        CAShapeLayer *line = [CAShapeLayer layer];
        line.fillColor = UIColorFromRGB(0xCBCBCB).CGColor;
        UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(_bottomView.width/2.0-0.5,
                                                                         20,
                                                                         1, _bottomView.height - 40)];
        line.path = path.CGPath;
        [_bottomView.layer addSublayer:line];
    }
    return _bottomView;
}


- (UIButton *)addFriendBtn{
    
    if (!_addFriendBtn) {
        _addFriendBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _addFriendBtn.size = CGSizeMake((KScreenWidth - 40)/2.0, 58);
        NSMutableAttributedString *aims = [@"  加好友" createAttributingByIcon:@"meat_found_friend" downIndexImage:nil textColor:UIColorFromRGB(0x666666) font:mFont(14)];
        [_addFriendBtn setAttributedTitle:aims forState:UIControlStateNormal];
        
    }
    return _addFriendBtn;
}


- (UIButton *)addShopBtn{
    if (!_addShopBtn) {
        _addShopBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _addShopBtn.size = CGSizeMake((KScreenWidth - 40)/2.0, 58);
        NSMutableAttributedString *aims = [@"  进店铺 " createAttributingByIcon:@"meat_found_shopIcon" downIndexImage:@"meat_found_down" textColor:UIColorFromRGB(0x666666) font:mFont(14)];
        [_addShopBtn setAttributedTitle:aims forState:UIControlStateNormal];
    }
    return _addShopBtn;
}

@end
